home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: vanyo@ibcco.com (Bill Vanyo)
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: Re: Multiple Indirection (Pointer Arithmatic)
- Date: 24 Mar 1996 11:51:04 -0600
- Organization: ABSnet Internet Services, Inc. - info@abs.net - (410)-361-8160
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4j4228$nvv@solutions.solon.com>
- References: <4j06ig$7q8@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
- X-Nntp-Posting-Host: ppp-175.ezaccess.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- R.Ghosh-Roy@brunel.ac.uk (R Ghosh-Roy) wrote:
-
-
- >I am a bit confused about "pointer arithmatic" and therefore would appreciate
- >your expert help. The following is the problem:
-
- Perhaps you're not confused.
-
- >I have three arrays (A,B,C) of structures and each structure has its own set
- >of fields. In structure A, one particular field Ab points to structure B. B
- >has a field Bc which points to C and C has a field named Cd. I need to look
- >for Cd for each A. Can I use some kind of clever pointer arithmatic to get
- >to Cd for each A? Or, is there a cleverer way?
-
- I'm going to go out on a limb here and say that there is no quicker
- way than to follow the 2 links.
-
- >Note: 3 arrays of structures A,B and C and only one field relates elements
- > of each array, ie, Ab relates to an element within an array of Bs and
- > Bc relates to an element within an array of Cs. These are dynamically
- > assigned.
-
- >struct A
- >|--------|
- >| |
- >| |
- >| |
- >| | struct B
- >| Ab ---|------->|--------|
- >| | | |
- >|--------| | |
- > | |
- > | |
- > | | struct C
- > | Bc ---|-------->|----------|
- > | | | |
- > | | | |
- > | | | |
- > |--------| | |
- > | |
- > | Cd |
- > | |
- > | |
- > | |
- > | |
- > |----------|
-
- >I was thinking of using sizeof and offsetof expressions.
-
- >Thanks,
-
- >Rana
-
-
- >--
- >R. Ghosh-Roy @ BIPS -- R.Ghosh-Roy@brunel.ac.uk -- Extension 2772
-